---
title: Relationship field
summary: >-
  The relationship field is a reference to the slug of a specific collection
  entry.
---
The `relationship` field is a reference to the `slug` of a specific collection entry. It renders a combobox in the Admin UI.

To create a one-to-many relationship, wrap the `relationship` field inside an [array field](/docs/fields/array).

{% aside icon="⚠️" %}
The collection string must match one of the keys used in the collections config object.
{% /aside %}

{% aside icon="☝️" %}
Heads up: the `relationship` field will only store a static `string` representing the `slug` of the selected collection entry.

If the slug of the entry in question changes, the stored value **will not be updated**. In other words, the relationship will be broken.
{% /aside %}

## Usage examples

Example of `has-one` relationship:

```typescript
country: fields.relationship({
  label: 'Country',
  description: 'The country this person lives in',
  collection: 'countries'
})
```

Example of `has-many` relationship:

```typescript
authors: fields.array(
  fields.relationship({
    label: 'Authors',
    description: 'A list of authors for this post',
    collection: 'posts'
  }), {
    label: 'Authors',
    itemLabel: props => props.value
  }
)
```

---

## Screencast walk-through

This segment of the [Keystatic Mini-Course on YouTube](https://www.youtube.com/playlist?list=PLHrxuCR-0CcSmkyLcmdV7Ruql8DTm644k) may help understand how the relationship field works:

{% embed
   mediaType="video"
   embedCode="<iframe src=\"https://www.youtube.com/embed/H3zdAOaXTFI?si=mDDK52Nlhg4v1v9x\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen></iframe>" /%}

---

## Type signature

Find the latest version of this field's type signature at: [https://docsmill.dev/npm/@keystatic/core@latest#/.fields.relationship](https://docsmill.dev/npm/@keystatic/core@latest#/.fields.relationship)
